<template>
  <div id="app">
    <p>{{ person.address }}</p>
    <button @click="handleClick">修改</button>
    <p>{{ arr[0] }}</p>
    <button @click="modifyArr">通过下表修改数组中的元素</button>
  </div>
</template>

<script>
import Vue from 'vue'
export default {
  name: 'App',
  data() {
    return {
      person: {
        name: 'ifer',
        age: 18,
      },
      arr: ['a', 'b', 'c'],
    }
  },
  methods: {
    handleClick() {
      // this.person.address = '河南'
      // 操作谁、操作哪个属性、值是什么
      // this.$set(this.person, 'address', '河南')
      Vue.set(this.person, 'address', '河南')
    },
    modifyArr() {
      // this.arr[0] = 'xxx'
      // this.$set(this.arr, 0, 'xxx')
      // Vue.set(this.arr, 0, 'xxx')
      this.arr.splice(0, 1, 'xxx')
    },
  },
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
